package server

import (
	"enjoy_wangyashuo/formdata"
	"enjoy_wangyashuo/internal/model/order"
	"github.com/pkg/errors"
)

func CreateOrder(data formdata.CreateOrder) error {
	stu := order.Order{
		UserId:          data.UserId,
		OrderId:         data.OrderId,
		OrderNumber:     data.OrderNumber,
		ShippingAddress: data.ShippingAddress,
		OrderStatus:     data.OrderStatus,
		PaymentStatus:   data.PaymentStatus,
		TotalAmount:     data.TotalAmount,
		Discount:        data.Discount,
		PaymentType:     data.PaymentType,
	}
	err := stu.CreateOrder()
	if err != nil {
		return err
	}
	return nil
}
func GetOrder(data formdata.OrderList) ([]order.Order, error) {
	res := order.Order{
		OrderId: data.OrderId,
	}
	list, err := res.OrderList()
	if err != nil {
		return nil, errors.New("列表查询失败")
	}
	return list, err
}
